package communication;

import java.io.Serializable;

import org.apache.log4j.Logger;

public final class CommunicationHelper {
	private CommunicationHelper() {
	}
	
	public static ParameterizedMessage buildErrorMsg(Object exception) {
		ParameterizedMessage errorMsg = new ParameterizedMessageImpl("ErrorMSG");
		errorMsg.setAttachment((Serializable) exception);
		return errorMsg;
	}
	
	public static void checkSystemProperty(Logger logger) {
		String tcpBindAddress = System.getProperty("jgroups.bind_addr");
		
		if (tcpBindAddress == null) {
			logger.warn("jgroups.bind_addr is not set, the default value will be used.");
		} else {
			logger.info("jgroups.bind_addr is set to be " + tcpBindAddress);
		}
		
		String initialHosts = System.getProperty("jgroups.tcpping.initial_hosts");
		
		if (initialHosts == null) {
			logger.warn("jgroups.tcpping.initial_hosts is not set, the default value will be used.");
		} else {
			logger.info("jgroups.tcpping.initial_hosts is set to be " + initialHosts);
		}
	}

}
